// store/index.ts
import { defineStore } from 'pinia'

export const useUserInfoStore = defineStore('useUserInfoStore', {
  // 定义 state
  state: () => {
    return {
      userInfo: {} as Record<string, any>,
      distributor: {} as Record<string, any>,
      manufacturer: {} as Record<string, any>,
      logistics: {} as Record<string, any>,
      inspection: {} as Record<string, any>,
      insurance: {} as Record<string, any>,
      recordCountry: '',
    }
  },
  // 定义 actions
  actions: {
    setUserInfo(obj: object): void {
      this.userInfo = obj
    },
    setStepInfo(key: string, obj: Record<string, any>): void {
      (this as Record<string, any>)[key] = obj
      console.log((this as Record<string, any>)[key])
    },
    setCountry(item: string) {
      this.recordCountry = item
    },
  },
  // eslint-disable-next-line node/prefer-global/process
  persist: process.client && {
    storage: localStorage,
  },
})
